From: Ben Hutchings Date: Tue, 8 Jan 2013 03:25:52 +0000 (+0000) Subject: radeon: Firmware is required for DRM and KMS on R600 onward X-Git-Tag: archive/raspbian/4.9.13-1+rpi1~126 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com//%22stanciumarius94%40gmail.com/%22/%22http:/www.example.com/%22stanciumarius94%40gmail.com/%22?a=commitdiff_plain;h=64b14e58b5447f4ffa2258206a6ea19f3e578ad6;p=linux-4.9.git radeon: Firmware is required for DRM and KMS on R600 onward radeon requires firmware/microcode for the GPU in all chips, but for newer chips (apparently R600 'Evergreen' onward) it also expects firmware for the memory controller and other sub-blocks. radeon attempts to gracefully fall back and disable some features if the firmware is not available, but becomes unstable - the framebuffer and/or system memory may be corrupted, or the display may stay black. This does not seem to happen if KMS is disabled, but with both KMS and GPU acceleration disabled radeon is not doing anything useful! Therefore, perform a basic check for the existence of /lib/firmware/radeon when a device is probed, and abort if it is missing, except for the pre-R600 KMS case. Gbp-Pq: Topic bugfix/all Gbp-Pq: Name radeon-firmware-is-required-for-drm-and-kms-on-r600-onward.patch --- diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 5b6a6f5b3619..a108a3eb59cc 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -42,6 +42,8 @@ #include "drm_crtc_helper.h" #include "radeon_kfd.h" +#include +#include /* * KMS wrapper. @@ -375,6 +377,42 @@ static struct drm_driver driver_old = { static struct drm_driver kms_driver; +/* Test that /lib/firmware/radeon is a directory (or symlink to a + * directory). We could try to match the udev search path, but let's + * assume people take the easy route and install + * firmware-linux-nonfree. + */ +static bool radeon_firmware_installed(void) +{ +#if IS_BUILTIN(CONFIG_DRM_RADEON) + /* It may be too early to tell. Assume it's there. */ + return true; +#else + struct path path; + + if (kern_path("/lib/firmware/radeon", LOOKUP_DIRECTORY | LOOKUP_FOLLOW, + &path) == 0) { + path_put(&path); + return true; + } + + return false; +#endif +} + +#ifdef CONFIG_DRM_RADEON_UMS +static int +radeon_ums_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + if (!radeon_firmware_installed()) { + DRM_ERROR("radeon DRM requires firmware-linux-nonfree.\n"); + return -ENODEV; + } + + return 0; +} +#endif + static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) { struct apertures_struct *ap; @@ -401,6 +439,12 @@ static int radeon_pci_probe(struct pci_dev *pdev, { int ret; + if ((ent->driver_data & RADEON_FAMILY_MASK) >= CHIP_R600 && + !radeon_firmware_installed()) { + DRM_ERROR("radeon kernel modesetting for R600 or later requires firmware-linux-nonfree.\n"); + return -ENODEV; + } + /* Get rid of things like offb */ ret = radeon_kick_out_firmware_fb(pdev); if (ret) @@ -623,6 +667,7 @@ static struct pci_driver *pdriver; static struct pci_driver radeon_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, + .probe = radeon_ums_pci_probe, }; #endif